package com.oplink.webems.modules.alarm.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import javax.persistence.CascadeType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.oplink.webems.modules.sys.entity.User;

/**
 * Alarm Status Entity
 * @author yizhang
 */
@Entity
@Table(name = "alarm_sts")
@DynamicInsert @DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AlarmStatus {
	
	private Long id;
	
	//状态ID
	private int stsid;
	
	private Date stime;
	
	private User user;
	
	private AlarmHistory ahist;
    
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public int getStsid() {
		return stsid;
	}

	public void setStsid(int stsid) {
		this.stsid = stsid;
	}

	public Date getStime() {
		return stime;
	}

	public void setStime(Date stime) {
		this.stime = stime;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="userid")
	@NotFound(action = NotFoundAction.IGNORE)	
	@JsonIgnore	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@OneToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE},optional=false)  
	@PrimaryKeyJoinColumn  
	public AlarmHistory getAhist() {
		return ahist;
	}

	public void setAhist(AlarmHistory ahist) {
		this.ahist = ahist;
	}
}
